/**
 * 
 */
package com.mobipe.sutto.util;

import java.io.File;
import java.nio.ByteBuffer;

/**
 * @author kohachiro
 *
 */
public class HttpRequest {
	public static String getUri(ByteBuffer byteBuffer) {
		for (int i=0;i<byteBuffer.capacity();i++){
			if (byteBuffer.get(i)==63||byteBuffer.get(i)==32||byteBuffer.get(i)==10){//"?"," ","\n"
				byte[] url=new byte[i];
				byteBuffer.get(url, 0, i);
				return new String (url);
			}
		}
		return null;
	}
	
    public static String sanitizeUri(String uri) {
        uri = uri.replace('/', File.separatorChar);
        if (uri.length()==1)
        	 return System.getProperty("user.dir") + File.separator + "htdocs" + File.separator + "index.htm";
        return System.getProperty("user.dir") + File.separator + "htdocs" + uri;
    }   	
}
